//
//  DoctorApplyController.m
//  KYProject
//
//  Created by Roman on 16/12/20.
//  Copyright © 2016年 Roman. All rights reserved.
//

#import "DoctorApplyController.h"
#import "RcyDoctorApplyCell.h"
#import "DoctorApplyModel.h"
#import "AppointmentDoctorController.h"

static NSString *cellID = @"cellID";
@interface DoctorApplyController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *modelList;

@end

@implementation DoctorApplyController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    
}



- (void)setupUI
{
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableView = tableView;
    [self.view addSubview:tableView];
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    
    self.tableView.rowHeight = 100;
    [self.tableView registerNib:[UINib nibWithNibName:@"RcyDoctorApplyCell" bundle:nil] forCellReuseIdentifier:cellID];
    
    [self getData];
}

- (void)getData
{
    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"Property List.plist" ofType:nil];
    
    NSArray *array = [NSArray arrayWithContentsOfFile:filePath];
    //创建可变数组来保存数据
    NSMutableArray *arrayM = [NSMutableArray array];
    
    for (NSDictionary *dic in array) {
        DoctorApplyModel *model = [[DoctorApplyModel alloc]init];
        [model yy_modelSetWithDictionary:dic];
        
        [arrayM addObject:model];
        
        self.modelList = arrayM.copy;
        
    }
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.modelList.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    RcyDoctorApplyCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
    
    
    
    cell.doctorModel = self.modelList[indexPath.row];
    
  
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    AppointmentDoctorController *doctorVC = [[AppointmentDoctorController alloc]init];
    
    doctorVC.model = self.modelList[indexPath.row];
    
    [self.navigationController pushViewController:doctorVC animated:YES];
}


@end
